<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客首页</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css" th:href="@{/css/me.css}" />
</head>
<body>
    <!-- 导航 -->
    <nav th:replace="admin/_fragments::menu(1)" class="ui inverted attached segment m-shadow-small">

    </nav>

    <!-- 二级导航 -->
    <div class="ui attached pointing menu">
        <div class="ui container">
            <div class="right menu">
                <a href="#" th:href="@{/admin/input}" class="item">发布</a>
                <a href="#" class="active teal item">列表</a>
            </div>
        </div>
    </div>

    <!-- 中间 -->
    <div class="m-container m-padded-tb-big">
        <div class="ui container">

            <!--/*/
        <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
          <i class="close icon"></i>
          <div class="header">提示：</div>
          <p th:text="${message}">恭喜，操作成功！</p>
        </div>
        /*/-->

            <form action="#" th:action="@{/admin/search}" method="post" class="ui secondary segment form">
                <div class="inline fields">
                    <div class="field">
                        <input type="text" name="title" placeholder="标题" />
                    </div>
                    <div class="field">
                        <div class="ui selection dropdown">
                            <input type="hidden" name="type" />
                            <i class="dropdown icon"></i>
                            <div class="default text">分类</div>
                            <div class="menu">
                                <div th:each="type : ${types}" class="item" data-value="1" th:data-value="${type.id}" th:text="${type.name}" >错误日志</div>
                            </div>
                        </div>
                    </div>
                    <div class="field">
                        <div class="ui checkbox">
                            <input type="checkbox" id="recommend" name="recommend">
                        </div>
                    </div>
                    <div class="field">
                        <button class="ui mini teal basic button" type="submit"><i class="search icon"></i>搜索</button>
                    </div>
                    <div class="field">
                        <a href="#" th:href="@{/admin/input}" class="ui mini teal basic button"><i class="add icon"></i>添加</a>
                    </div>
                </div>
            </form>

            <table class="ui compact purple table">
                <thead>
                    <tr>
                        <th></th>
                        <th>标题</th>
                        <th>类型</th>
                        <th>推荐</th>
                        <th>更新时间</th>
                        <th>操作</th>
                    </tr>
                </thead>

                <tbody>
                    <tr th:each="blog:${pages.list}">
                        <td th:text="${blog.id}">1</td>
                        <td th:text="${blog.title}">好男人</td>
                        <td th:text="${blog.type.name}">认知升级</td>
                        <td th:text="${blog.recommend==true?'是':'否'}">是</td>
                        <td th:text="${#temporals.format(blog.updateTime, 'yyyy-MM-dd HH:mm')}">2020-01-01 01:11</td>
                        <td>
                            <a href="#" th:href="@{/admin/blogs/{id}/input(id=${blog.id})}" class="ui mini teal basic button">编辑</a>
                            <a href="#" th:href="@{/admin/blogs/{id}/delete(id=${blog.id})}" onclick="return confirm('您确定要删除吗？')" class="ui mini red basic button">删除</a>
                        </td>
                    </tr>
                </tbody>

                <tfoot>
                    <tr>
                        <th colspan="6">
                            <div class="ui pagination menu">
                                <a th:href="@{/admin/index(pageNum=${pages.hasPreviousPage}?${pages.prePage}:1)}" class="item">上一页</a>
                                <a th:href="@{/admin/index(pageNum=${pages.hasNextPage}?${pages.nextPage}:${pages.pages})}" class="item">下一页</a>
                            </div>
                            <div class="ui mini segment m-inline-block">
                                <p>当前第<span th:text="${pages.pageNum}"></span>页，总<span th:text="${pages.pages}"></span>页，共<span th:text="${pages.total}"></span>条记录</p>
                            </div>
                        </th>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>

    <br>
    <br>
    <br>

    <!-- 底部 -->
    <footer th:replace="admin/_fragments::footer" class="ui inverted vertical segment m-padded-tb-massive">

    </footer>


    <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>


    <script>
        $('.menu.toggle').click(function () {
            $('.m-item').toggleClass('m-mobile-hide');
        });

        $('.ui.dropdown').dropdown({
            on : 'hover'
        });

        //消息提示关闭初始化
        $('.message .close')
            .on('click', function () {
                $(this)
                    .closest('.message')
                    .transition('fade');
            });

    </script>
</body>
</html>